package cc.wsyw126.java.nowcoder.sword_offer;

import java.util.LinkedList;

/**
 * Created by dp on 17/3/29.
 */
public class Mirror {
    public void Mirror(TreeNode root) {
        if (root == null) return;
        LinkedList<TreeNode> queue = new LinkedList<>();
        queue.add(root);
        while (!queue.isEmpty()) {
            TreeNode pop = queue.pop();
            TreeNode right = pop.right;
            TreeNode left = pop.left;
            pop.right = left;
            pop.left = right;
            if (left != null) {
                queue.add(left);
            }
            if (right != null) {
                queue.add(right);
            }
        }
    }
}
